Skip to content

fix: support ESLint 10 by using context.sourceCode property - #15

Merged
aryelu merged 1 commit into
mainfrom
claude/eslint-plugin-code-complete-gcjn95
Aug 24, 2026
Merged

fix: support ESLint 10 by using context.sourceCode property#15
aryelu merged 1 commit into
mainfrom
claude/eslint-plugin-code-complete-gcjn95

Conversation

@aryelu

@aryelu aryelu commented Aug 24, 2026

Copy link
Copy Markdown
Owner

Description

This PR adds ESLint 10 compatibility to the plugin by updating rules to use the context.sourceCode property instead of the deprecated context.getSourceCode() method, which was removed in ESLint 10.

A new helper function getSourceCode() in utils/node-helpers.ts provides backward compatibility by preferring the property and falling back to the method for older ESLint versions.

Fixes #14

Type of change

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

Added comprehensive regression tests in tests/eslint10-compatibility.test.ts that:

  • Create a mock ESLint 10 context with only the sourceCode property (no getSourceCode method)
  • Verify that no-complex-conditionals rule works correctly without context.getSourceCode()
  • Verify that max-function-length rule works correctly without context.getSourceCode()

Both test cases confirm the rules properly report violations when using only the ESLint 10 API.

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

https://claude.ai/code/session_01GHzmaqnfUrfLno7pHBPeSq

ESLint 10 removed the deprecated `context.getSourceCode()` method, so
`no-complex-conditionals` and `max-function-length` threw
`TypeError: context.getSourceCode is not a function` when linting under
ESLint 10.

Add a `getSourceCode()` helper that prefers the `context.sourceCode`
property and only falls back to the method when the property is absent,
and use it in both rules. Adds regression tests that drive the rules with
an ESLint 10 style context that has no `getSourceCode` method.

Fixes #14

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GHzmaqnfUrfLno7pHBPeSq
@aryelu
aryelu merged commit 114cb14 into main Aug 24, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] code-complete/no-complex-conditionals fails in eslint 10 due to missing context.getSourceCode()

2 participants